package edu.fiu.cis.selfhealingdisk;


/**
 * @author vanvorst
 *
 */
public class BlockUnit{
	public enum BlockTypeEnum {
		DATA_BLOCK, PARITY_BLOCK,
	};
	private final Long id;
	private final ParityGroup parityGroup;
	private final long startBlock;
	private final long blockCount;
	private final BlockTypeEnum type;
	private long lastUpdate;

	/**
	 * @param parityGroup
	 * @param id
	 * @param startBlock
	 * @param blockCount
	 * @param type
	 */
	public BlockUnit(ParityGroup parityGroup, Long id, long startBlock, long blockCount, BlockTypeEnum type) {
		this.id=id;
		this.parityGroup = parityGroup;
		this.startBlock = startBlock;
		this.blockCount = blockCount;
		this.type = type;
		this.lastUpdate = 0;		
	}

	/**
	 * @return the lastUpdate
	 */
	public final long getLastUpdate() {
		return lastUpdate;
	}

	/**
	 * @param lastUpdate the lastUpdate to set
	 */
	public final void setLastUpdate(long lastUpdate) {
		this.lastUpdate = lastUpdate;
		this.parityGroup.updateDataUnit(this);
	}


	/**
	 * @return the id
	 */
	public final Long getId() {
		return id;
	}

	/**
	 * @return the startBlock
	 */
	public final long getStartBlock() {
		return startBlock;
	}

	/**
	 * @return the blockCount
	 */
	public final long getBlockCount() {
		return blockCount;
	}

	/**
	 * @return the type
	 */
	public final BlockTypeEnum getType() {
		return type;
	}
}